package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsArticleMapper;
import com.qf.pojo.DtsArticle;
import com.qf.service.DtsArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Zwnan
 */
@Service
public class DtsArticleServiceImpl implements DtsArticleService {
    @Autowired
    private DtsArticleMapper dtsArticleMapper;
    @Override
    public IPage<DtsArticle> findPage(Integer page, Integer limit, String sort, String order) {
        IPage<DtsArticle> iPage = new Page<>(page,limit);


        return dtsArticleMapper.selectPage(iPage,new QueryWrapper<DtsArticle>().eq("deleted", false));
    }

    @Override
    public void create(DtsArticle dtsArticle) {
        dtsArticleMapper.insert(dtsArticle);
    }

    @Override
    public void update(DtsArticle dtsArticle) {
        dtsArticleMapper.updateById(dtsArticle);

    }

    @Override
    public void delete(DtsArticle dtsArticle) {
        dtsArticle.setDeleted(true);
        dtsArticleMapper.updateById(dtsArticle);
    }
}
